package com.zlcx.tz.live.constant;

/**
 * 学习状态
 */
public enum LearningStatus {

    NO_TIMING("no_timing","未学习", 1),
    LEARN_TIMING("learn_timing", "学习计时中", 2),
    LIAN_MAI_TIMING("lian_mai_timing", "连麦学习中", 3),
    LEARN_TIMING_PAUSE("learn_timing_pause", "学习计时暂停中", 12),
    LEARN_TIMING_CONINUE("learn_timing_continue", "学习计时继续中", 13),
    TIME_LEARN_ROOM("time_learn_room", "计时自习室学习中", 60),
    ;

    LearningStatus(String info, String tips, int code) {
        this.info = info;
        this.tips = tips;
        this.code = code;
    }

    private String info;
    private String tips;
    private int code;

    public String getInfo() {
        return info;
    }

    public void setInfo(String info) {
        this.info = info;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getTips() {
        return tips;
    }

    public void setTips(String tips) {
        this.tips = tips;
    }

    public static LearningStatus getLearningStatus(int code) {
        for (LearningStatus field : LearningStatus.values()) {
            if (code == field.getCode()) {
                return field;
            }
        }
        return null;
    }

    public static boolean ifLearningStart(Integer code) {
        if (null == code) {
            return false;
        }
        LearningStatus learningStatus = getLearningStatus(code);
        if (learningStatus == LEARN_TIMING || learningStatus == LIAN_MAI_TIMING || learningStatus == TIME_LEARN_ROOM) {
            return true;
        }
        return false;
    }

    public static boolean ifOrdernaryLearn(Integer code) {
        if (null == code) {
            return false;
        }
        LearningStatus learningStatus = getLearningStatus(code);
        if (learningStatus == LEARN_TIMING || learningStatus == LEARN_TIMING_PAUSE || learningStatus == LEARN_TIMING_CONINUE) {
            return true;
        }
        return false;
    }

    public static boolean canPause(Integer code) {
        if (null == code) {
            return false;
        }
        if (code == LEARN_TIMING.code || code == LEARN_TIMING_CONINUE.code || code == TIME_LEARN_ROOM.code) {
            return true;
        }
        return false;
    }
}
